package thread;

/**
 * Creared with IntelliJ IDEA.
 * Description:按顺序打印cba
 * User:yxd
 * Date:2022-03-26
 * Time:21:35
 */
public class Demo17 {
    private static Object o = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            System.out.println(Thread.currentThread().getName());

        },"c");
        Thread t2 = new Thread(()->{
            try {
                t1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());


        },"b");
        Thread t3 = new Thread(()->{
            try {
                t2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());

        },"a");
        t1.start();
        t2.start();
        t3.start();
    }
}
